package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.print.DocFlavor;
import java.util.List;

/**
 * Created by Ray on 2018/10/22/022
 */
@RestController
public class DcController {
    @Autowired
    DiscoveryClient discoveryClient;

    @GetMapping("/dc")
    public String dc() {
       List<String> servers = discoveryClient.getServices();
        System.out.println("producer" + servers);
        return servers.get(0);
    }

    @GetMapping("/add")
    public String add() {
        String mess = "验证是否是引入discoveryClient,就已经注册";
        return mess;
    }
}
